package com.hctrl.mybatis.interceptor.handler;

import cn.hutool.core.date.DatePattern;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author hanchao
 * @version 1.0
 * @date 2022/5/29 2:05
 */
public class DateTypeHandler implements TypeHandler<Date> {

    private SimpleDateFormat sdf = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);

    @Override
    public Boolean isSupport(Class<?> type) {
        return type.equals(Date.class);
    }

    @Override
    public String handler(Date date) {

        String format = sdf.format(date);
        return new StringBuilder().append("'").append(format).append("'").toString();
    }
}
